package com.zyw.weibo.data.remote;

import java.io.IOException;

import org.json.JSONException;

import com.zyw.weibo.ui.R;

import android.content.Context;

public class CodeException extends Exception {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	protected String data = null;
	
	public CodeException(String code,String message){
		super(message+"(code:"+code+")");
	}
	
	private CodeException(String code,String message,Throwable throwable){
		super(message+"(code:"+code+")",throwable);
	}
	
	public void setData(String data){
		this.data = data;
	}
	
	public String getData(){
		return data;
	}
	
	public static CodeException getIOCodeException(Context context,IOException e){
		return new CodeException("-1",context.getString(R.string.generic_neterror),e);
	}
	
	public static CodeException getJSONCodeException(Context context,JSONException e){
		return new CodeException("-2",context.getString(R.string.generic_jsonerror),e);
	}
	
}
